package com.shanling.shanlingcontroller.view;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.shanling.shanlingcontroller.R;

/**
 * Created by ch1 on 2019/10/11.
 */

public class MyDilalogUtils extends Dialog{
    private OnDialogClickListener listener;



    public MyDilalogUtils(@NonNull final Context context, int themeResId,String t,String c ) {
        super(context, themeResId);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.mydialog, null);
        TextView title = view.findViewById(R.id.tv_title);
        TextView content = view.findViewById(R.id.tv_content);
        TextView queding = view.findViewById(R.id.tv_cancle);
        TextView cancel = view.findViewById(R.id.tv_confirm);
        title.setText(t);
        content.setText(c);
        setContentView(view);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onSure();
                dismiss();
            }
        });
        queding.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onCancel();
                dismiss();
            }
        });
        this.getWindow().setGravity(Gravity.CENTER);

    }
    public interface OnDialogClickListener {
        void onSure();

        void onCancel();
    }

    public void setOnDialogClickListener(OnDialogClickListener listener) {
        this.listener = listener;
    }



}
